import type { } from '@/api/system/user/type'

import request from '@/util/request'
import type { SysPermission, SysPermissionTreeVO } from './type'

enum API {
    SYS_PERMISSION_BASE_URL = "/system/permission",
    SYS_PERMISSION_LIST_URL = "/system/permission/tree-list",
    SYS_PERMISSION_FOLDER_URL = '/system/permission/folder'
}
/**
 * 获取权限树集合
 * @param sysPermission
 * @returns
 */
export function reqGetSysPermissionTreeList( sysPermission : any) {
    return request<SysPermissionTreeVO[]>({
        url: API.SYS_PERMISSION_LIST_URL,
        method: 'get',
        params: sysPermission
    })
}
/**
 * 新增一个权限
 * @param sysPermission
 * @returns
 */
export function reqAddSysPermission(sysPermission: SysPermission) {
    return request<null>({
        url: API.SYS_PERMISSION_BASE_URL,
        method: 'post',
        data: sysPermission
    })
}
export function reqGetSysPermission(permissionId: string | number) {
    return request<SysPermission>({
        url: API.SYS_PERMISSION_BASE_URL + `/${permissionId}`,
        method: 'get',
    })
}
/**
 * 修改权限
 * @param sysPermission
 * @returns
 */
export function reqModifySysPermission(sysPermission: SysPermission) {
    return request<null>({
        url: API.SYS_PERMISSION_BASE_URL,
        method: 'put',
        data: sysPermission
    })
}

export function reqDeleteSysPermission(permissionId: string | number) {
    return request<null>({
        url: API.SYS_PERMISSION_BASE_URL + `/${permissionId}`,
        method: 'delete',
    })
}
/**
 * 获取非按钮（功能性）权限
 * @returns
 */
export function reqGetSysPermissionFolder() {
    return request<SysPermissionTreeVO[]>({
        url: API.SYS_PERMISSION_FOLDER_URL,
        method: 'get',
    })
}
